--[[ DEAD (deprecated) CODE LOL!
Object = {
	ID="",
	Source=nil,
	ref=nil,
	x=0,y=0,
}
function Object:new()
	local new = Copy(self)
	new.ref=ITEMS[self.ID]
	new.Source = new.ref.Source
	
	if new.Init then new.Init() end
	return new
end
function Object:Init() end
function Object:Update() end
function Object:Draw() end
]]--


RedstoneDust = {
	Source = nil,
	ID="redCrossOff",
	power=0
}
class(RedstoneDust)
--Merge(redstoneDust, instance)

function RedstoneDust:new(x,y)
	self.x,self.y = x,y
	self.ref = ITEMS[self.ID]
	self.Source = self.ref.Source
end

function RedstoneDust:Init()
	--print("Redstone Initialized")
end

function RedstoneDust:Draw()
	local gw,gh = MainScene.GridWidth,MainScene.GridHeight
	local x,y = self.x,self.y
	local n,s = MainScene:getTile(x,y-1),MainScene:getTile(x,y+1)
	local e,w = MainScene:getTile(x-1,y),MainScene:getTile(x+1,y)
	
	local sx,sy,sw,sh = self.Source.x,self.Source.y,self.Source.w,self.Source.h
	local dx,dy,dw,dh = x*gw, y*gh, gh,gh

	local cw,ch = gw*(2/16),gh*(2/16)
	
	if (n or s) and not (e or w) then
		graphics.drawPart(sheet, dx,dy, dw,dh, sx,sy,sw,sh-10)
	elseif (e or w) and not (n or s) then
		graphics.drawPart(sheet, dx,dy, dw,dh, sx,sy,sw-10,sh)
	elseif (n or s or e or w) then
		if n then
			graphics.drawPart(sheet, dx,dy, dw,dh-gh/2-ch, sx,sy,sw,sh-10)
		end
		if s then
			graphics.drawPart(sheet, dx,dy+gh/2+cw, dw,dh-gh/2, sx,sy+10,sw,sh-10)
		end
		if e then
			graphics.drawPart(sheet, dx,dy, dw-gw/2-cw,dh, sx,sy,sw-10,sh)
		end
		if w then
			graphics.drawPart(sheet, dx+gw/2+cw,dy, dw-gw/2,dh, sx+10,sy,sw-10,sh)
		end	
		
		graphics.drawPart(sheet, dx+gw/2-cw/2,dy+gh/2-ch/2, cw,ch, sx+5,sy+5,sw-10,sh-10)
	else
		graphics.drawPart(sheet, dx,dy, dw,dh, sx,sy,sw,sh)
	end
end

print("Redstone Loaded")